{extend name="page_base" /} {block name="seo"}
<title>意见反馈 - {$site_config['seo_title']}</title>
<meta name="keywords" content="{$site_config['seo_keyword']}">
<meta name="description" content="{$site_config['seo_description']}">
{/block}
{block name="css"}

{/block}
{block name="body"}
<div class="page page-current">
    <div class="content native-scroll">
        <header id="header" class="clearfix theader">
            <a href="/" class="back iconfont icon-fanhui"></a>
            <h3 class="titlea">意见反馈</h3>
        </header>
        <div class="thisContent">
            <form class="idea" id="save_form" onsubmit="return false">
                <textarea name="opinion" placeholder="请输入您要反馈的内容"></textarea>
                <input name="qq" type="text" maxlength="11" placeholder="请输入您的QQ联系方式">
                <input name="captcha" lay-verify="required" maxlength="4" type="text" placeholder="验证码" style="margin:0;float:left;width:calc(100% - 144px);">
                <img src="{:url('index/page/captcha')}?'+Math.random();" id="img_code" title="点击可刷新图形码" style="width:144px;height:2rem;" onclick="this.src='{:url(\'index/page/captcha\')}?_='+Math.random()"/>
                <input type="submit" value="提交反馈" class="btn save_btn">
            </form>
        </div>
        {include file="index/footer"}
    </div>
</div>
{/block}
{block name="script"}
<script>
    $(".save_btn").click(function () {

        var form_obj = $("#save_form");
        var data = form_obj.field();
        // var reg_url = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
        var reg_qq =  /^[1-9]([0-9]{5,11})$/;
        var ck_sub = form_obj.verify({

            opinion: function (value, item) {
                if (value.length < 10 || value.length > 300) {
                    return '请输入10到300位字符';
                }
            },
            qq: function (value, item) {
                if (!reg_qq.test(value)) {
                    return 'QQ格式不正确！';
                }
            },
            captcha:function (value, item) {
                if (value.length != 4) {
                    return '验证码长度是4位哦！';
                }
            }

        })

        if(ck_sub){
            $.ajax({
                type: "Post",
                url:'/about/idea.html',
                data:{
                    data:data,
                    post_type:'add_opinion'
                },
                dataType: "json",
                success: function(res){
                    $("#img_code").click();
                    $("#img_code").trigger("click");
                    $.alert(res.msg, function () {
                        (res.code === 1) && location.reload();
                    });

                }
            });
        }
    })
</script>
{/block}